package com.xueyi.aixihu.controller;

import com.xueyi.aixihu.controller.base.BaseController;
import com.xueyi.aixihu.entity.vo.DtFeedBackTotalVo;
import com.xueyi.aixihu.entity.vo.DtyybmVo;
import com.xueyi.aixihu.reqeust.DtFindByFeedBackListReq;
import com.xueyi.aixihu.reqeust.InsertMessageContentReq;
import com.xueyi.aixihu.response.DtFeedBackResponse;
import com.xueyi.aixihu.response.base.BaseResponse;
import com.xueyi.aixihu.service.LocalDtFeedBackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yuyu
 * @date : 2022/8/16
 * @Description : 留言反馈的接口层
 */
@RestController
public class LocalDtFeedBackController extends BaseController {
    //注入service层
    @Autowired
    private LocalDtFeedBackService localDtFeedBackService;

    /**
     * 查询反馈集合
     * @param dtFindByFeedBackListReq
     * @return
     */
    @PostMapping("/find/feedBackList")
    public DtFeedBackResponse findByFeedBackList(DtFindByFeedBackListReq dtFindByFeedBackListReq) {
        DtFeedBackResponse response = localDtFeedBackService.findByFeedBackList(dtFindByFeedBackListReq);
        return response;
    }

    /**
     * 查看单条反馈信息
     * @param id
     * @return
     */
    @PostMapping("/findOne/feedBack")
    public BaseResponse<DtyybmVo> viewInformation(Integer id) {
        BaseResponse<DtyybmVo> response = localDtFeedBackService.viewInformation(id);
        return response;
    }

    /**
     * 改变留言状态
     * @param id
     * @param isValid
     * @return
     */
    @PostMapping("/update/feedBackIsValid")
    public BaseResponse updateIsValid(Integer id, Integer isValid) {
        BaseResponse baseResponse = localDtFeedBackService.updateIsValid(id, isValid);
        return baseResponse;
    }

    /**
     * 查询留言反馈的各种状态的条数
     * @return
     */
    @PostMapping("/select/feedBackMoreTotal")
    public BaseResponse<DtFeedBackTotalVo> findFeedBackTotal(String name) {
        BaseResponse<DtFeedBackTotalVo> response = localDtFeedBackService.findFeedBackTotal(name);
        return response;
    }

    /**
     *  回复反馈信息
     * @param id
     * @param content
     * @return
     */
    @PostMapping("/update/leavingMessage")
    public BaseResponse updateLeaving(Integer id, String content) {
        BaseResponse response = localDtFeedBackService.updateLeaving(id, content);
        return response;
    }

    /**
     * 发送留言信息
     *
     * @param insertMessageContentReq
     */
    @PostMapping("/insert/insertMessageContent")
    public BaseResponse<Boolean> insertMessageContent(InsertMessageContentReq insertMessageContentReq) {

        return localDtFeedBackService.insertMessageContent(insertMessageContentReq);
    }
}
